import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		// 城市组件
		cityMap: new Map(),
		cityInfo: {
			name: "深圳市"
		},
		// 滚动组件
		tabIndex: 0,
		// 用户信息
		userInfo:{sex:1},
		// 动态切换组件
		trendTabIndex:0,
		// 举报图片选择
		tipImageList:[],
		// 选择动态话题
		selectTopic:{},
		// 选中的标签
		selectTag:{},
		chatInfo:{
			unReadMessageNum: 0,
			friendList:[],
			
		},
		chatTabIndex:0,
		searchText:''
	},
	mutations: {
		setCityMap(state, cityMap) {
			state.cityMap = cityMap;
		},
		setCityInfo(state, item) {
			const citys = state.cityMap.get(item.key);			
			citys.some(ie=>{
				if(ie.name === item.name){
					state.cityInfo = ie;
					return true;
				}
				return false;
			})
		},
		setTabIndex(state,index) {
			state.tabIndex=index;
		},
		setTrendTabIndex(state,index) {
			state.trendTabIndex=index;
		},
		setChatTabIndex(state,index) {
			state.chatTabIndex=index;
		},
		setTipImageList(state,tipImageList){
			state.tipImageList=tipImageList;
		},
		setSelectTopic(state,selectTopic){
			state.selectTopic=selectTopic;
		},
		setSelectTag(state,selectTag){
			state.selectTag=selectTag;
		},
		setSearchText(state,searchText){
			state.searchText=searchText;
		}
	},
	actions: {}
})

export default store
